/*creates a menu in a grid style (array of menus)
    -position
  param0 = x
  param1 = y
    -contents
  param2 = text[][]
  parem3 = intentType[][]
  param4 = intent[][]
  param5 = title
    -dimensions
  param6 = pixelWidth
  param7 = pixelHeight
    -visible
  param8= visible
    -if a level selection menu
  param9= levelSelect
*/

var X=argument0;
var Y=argument1;
var text=argument2;
var intentType=argument3;
var intent=argument4;
var titleInput=argument5;
var gridWidth=argument6;
var gridHeight=argument7;
var visibility=argument8;
var levelSelection=argument9;

var gridMenu=instance_create(X,Y,oGridMenu);

with(gridMenu){
    //init vars
    width=gridWidth;
    height=gridHeight;
    
    //create columns
    var titleHeight=70;
    var horSpacing=width/array_length_2d(text,0);
    var whiteSpace=20;
    for(var i=0;i<array_length_2d(text,0);i++){
        var arText, arIntentType,arIntent;
        for(var j=0;j<array_height_2d(text);j++){
            arIntentType[j]=intentType[j,i];
            if(arIntentType[j]==INTENT_TYPE_NONE)
                continue;
            arText[j]=text[j,i];   
            arIntent[j]=intent[j,i];
        }
        menuColumn[i]=menuConstructor(X+horSpacing*i,Y+titleHeight,arText,arIntentType,arIntent,"",
            horSpacing-whiteSpace,height-titleHeight,visibility,levelSelection);
    }
    //standard variables
    usingMouse=true;
    title=titleInput;
   
    mouse_prevx=mouse_x;
    mouse_prevy=mouse_y;
    visible=visibility;
    lvlSel=levelSelection;
    menuIndex=-1;
    
    init=true;
}
return gridMenu;
